package cn.tedu.contrlloer;

import cn.tedu.pojo.Student;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.sql.Connection;
import java.sql.Date;
import java.sql.DriverManager;
import java.sql.PreparedStatement;

@RestController
@RequestMapping("stu")
@CrossOrigin//
public class StuContrller {
    @RequestMapping("eat1")
    public Student eat1(Student s) throws Exception {
        System.out.println(s);
        return s;
//        Class.forName("com.mysql.jdbc.Driver");
//        Connection conn = DriverManager.getConnection("jdbc:mysql:///mydemo1", "root", "root");
//        String sql ="insert into student(name,age,sex,hobby,edu,intime) values (?,?,?,?,?,?)";
//        PreparedStatement ps = conn.prepareStatement(sql);
//        ps.setString(1, s.getName());
//        ps.setInt(2,s.getAge());
//        ps.setString(3,s.getSex());
//        ps.setString(4,s.getHobby()[0]);
//        ps.setString(5,s.getStu());
//        java.sql.Date s1 =new Date(s.getIntime().getTime());
//        ps.setDate(6,s1);
//
//        ps.executeUpdate();
//        ps.close();
//        conn.close();
    }
}
